package com.joker.warehouse.controller;

import com.joker.common.core.domain.Result;
import com.joker.warehouse.domain.vo.PurchaseNeedVO;
import com.joker.warehouse.service.INeedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lemon
 * @date 2025/01/13 20:19
 **/
@RestController
@RequestMapping("/need")
public class NeedController {


    @Autowired
    private INeedService needService;

    /**
     * 商家 生成采购需求
     * @param skuId skuId
     * @return 响应
     */
    @PostMapping("/create/{skuId}")
    private Result create(@PathVariable Long skuId){
        needService.createNeed(skuId);
        return Result.success();
    }

    /**
     * 商家 查询供应商下未进行采购的采购需求
     * @param supplierId 供应商id
     * @return 采购需求集合
     */
    @GetMapping("/selectBySuppId/{supplierId}")
    private Result<List<PurchaseNeedVO>> selectBySuppId(@PathVariable Long supplierId){
        List<PurchaseNeedVO> needs =needService.selectBySuppId(supplierId);
        return Result.success(needs);
    }
}
